<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <title>添加</title>
    <%@ include file="/WEB-INF/taglib.jsp" %>
    <%@ include file="/WEB-INF/jsp/loading.jsp" %>
    <%@ include file="/WEB-INF/jsp/include.jsp" %>
    <script type="text/javascript"  src="${path}/resource/js/jquery/jquery-easyui-1.4.5/extends/jquery.layout.extend.js"></script>

    <script type="text/javascript" src="${path}/resource/js/system/declareparameter/common.js"></script>
    <script type="text/javascript" src="${path}/resource/js/system/declareparameter/DateUtils.js"></script>
    <script type="text/javascript">
        var path = "${path}";
        var params = new Object();
        // 此段代码处于 顶层（top） 页面中
        $(function () {
            setAjaxLoading();
            init();
            $("#sel_ssq_xh").combobox({
                required: false,
                editable: false,
                panelHeight: 200,
                valueField: "code",
                textField: "name",
                onSelect: function(record) {
                    calculateSsq();
                }
            });

            $("#ledger").combobox({
                onChange: function (dictCode,o) {
                    //新增数据来源，删除数据来源调用方法一样
                    params.ldgTypeCode = dictCode;
//                    params.cbid = $("#taxPayers").combobox("getValue");
                    var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
                    var nodes =[];
                    if(treeObj!=null) {
                        nodes = treeObj.getSelectedNodes();
                        params.cbid = nodes[0].id;
                    }else{
                        params.cbid ="";
                    }
                    $.ajax({
                        type: "POST",
                        url: path + "/tdm/declareParameter/deleteOrAddLedger",
                        data: params,
                        dataType: "json",
                        success: function callback(data) {
                            var analyMsg = data.returnObject;
                            if (data.code == "0000") {

                            } else {

                            }
                        }
                    });
                }

            });
            $("#sel_sbzq").combobox({
                onChange: function(record) {
                    
                    changePerd("sel_sbzq", "sel_ssq_nd");
                    
                    var taxCode = $("#sel_sz").combobox("getValue");
                    //属期
                    var period = $("#sel_sbzq").combobox("getValue");
                    $.ajax({
                        type:"POST",
                        url:path+"/tdm/declareParameter/showledgerList?taxCode="+taxCode+'&period='+period,
                        dataType:"json",
                        success:function callback(data){
                            var analyMsg = data.returnObject;
                            if (data.code=="0000") {
                                var dataList =[];
                                $("#ledger").combobox("clear");
                                if(analyMsg.length>0){
                                    for(var i=0;i<analyMsg.length;i++){
                                        dataList.push({"value": analyMsg[i].dictCode,"text":analyMsg[i].dictName});
                                    }
                                    $("#ledger").combobox("loadData",dataList);

                                    if(analyMsg.length==1){
                                        $('#ledger').combobox('setValue', analyMsg[0].dictCode);
                                    }
                                }
//                                init();
                            } else {
//                                $.messager.alert('操作提示',data.msg,'info',function(){});
                            }
                        }
                    });

                    refresh_ssq_xh_update(period);
                }

            });
//
            $("#sel_sz").combobox({

                onSelect: function(record) {
                    var param = new Object();
                    param.dictCode=$("#sel_sz").combobox("getValue");
                    $.ajax({
                        type : "POST",
                        url : path+'/tdm/declareParameter/queryDeclarePeriod',
                        dataType : "json",
                        data: param,
                        success : function callback(data) {
                            if (data.code == '0000') {
                                var rows = data.returnObject;

                                var dict = rows.dictDto;
                                //汇总类型
                                var gatherType = rows.gatherType;
                                //如果汇总类型为02 汇总显示汇总分支结构
                                if(gatherType == '02'){
                                    $('#cc').layout('show',"west");

                                }else{
                                    $('#cc').layout('hidden',"west");
                                }
                                var dataList =[];
                                if(dict.length>0){
                                    for(var i=0;i<dict.length;i++){
                                        dataList.push({"value": dict[i].dictCode,"text":dict[i].dictName});
                                    }
                                    $("#sel_sbzq").combobox("clear");

                                    $("#sel_sbzq").combobox("loadData",dataList);
                                    if(dict.length==1){
                                        $('#sel_sbzq').combobox('setValue', dict[0].dictCode);
                                    }
                                }
                            }
                        },
                        error : function(data, textstatus) {
                            $.messager.alert('错误', data.responseText, 'error',function(){});
                        }
                    });
                }

            });
            
        });

        function refresh_ssq_xh_update(sbzq_dm) {

            var myDate = new Date();
            var year =   $("#sel_ssq_nd").val();   //获取完整的年份(4位,1970-????)
            var month= myDate.getMonth()+1;       //获取当前月份(0-11,0代表1月)
            var day = myDate.getDate();        //获取当前日(1-31)

            var iCount = 0;
            if ("01" == sbzq_dm) {
                iCount = 12;

                if(day>15){
                    month = month;
                }else{
                    month = month-1;
                }

            } else if ("03" == sbzq_dm) {
                iCount = 4;

                if(month>1&&month<=3){
                    month =1 ;
                }
                if(month>3&&month<=6){
                    month =2 ;
                }
                if(month>6&&month<=9){
                    month =3 ;
                }
                if(month>9&&month<=12){
                    month =4 ;
                }
            } else if ("06" == sbzq_dm) {
                iCount = 2;

                if(month>1&&month<=6){
                    month =1 ;
                }
                if(month>6&&month<=12){
                    month =2 ;
                }
            } else if ("12" == sbzq_dm) {
                $("#sel_ssq_xh").combobox("clear");
                $("#sel_ssq_xh").combobox("loadData", []);
                $("#sel_ssq_xh").combobox("disable");

                // $("#txt_ssq_q").attr("disabled", "disabled");
                // $("#txt_ssq_z").attr("disabled", "disabled");
                month = 0;
            }
            // $("#txt_ssq_q").removeAttr("disabled");
            // $("#txt_ssq_z").removeAttr("disabled");
            if (iCount > 0) {
                var arr_xh = new Array();
                arr_xh.push({"code": "-1", "name":""});
                for (var i = 1; i <= iCount; i++) {
                    var item = new Object();
                    item.code = i;
                    item.name = item.code;
                    arr_xh.push(item);
                }

                $("#sel_ssq_xh").combobox("clear");
                $("#sel_ssq_xh").combobox("loadData", arr_xh);
                $("#sel_ssq_xh").combobox("enable");

            }
            if(month == 0){
                $("#sel_ssq_xh").combobox("setValue", "");
            }else{
                $("#sel_ssq_xh").combobox("setValue", month);
            }

            $("#sel_ssq_nd").val(year);

            calculateSsq();
        }

        function init() {
            var cbid = $("#cbid").val();
            var cpid = $("#cpid").val();
            $.ajax({
                type: "POST",
                url: "/tdm/declareParameter/updateInit?cbid=" + cbid+"&cpid="+cpid,
                dataType: "json",
                //data: param,
                success: function callback(data) {
                    if (data.code != '0000') {
                        $.messager.alert('错误', data.msg, 'error', function () {
                        });
                    } else {
                        var analyMsg = data.returnObject;


                        var startDate = (new Date(analyMsg.startDate)).Format("yyyy-MM-dd")

                        var endDate = (new Date(analyMsg.endDate)).Format("yyyy-MM-dd")
                        
                        $("#txt_ssq_q").val(startDate);
                        $("#txt_ssq_z").val(endDate);

                        $('#sel_sz').combobox('setValue', analyMsg.taxCode);
                        
                        if(analyMsg.gatherType == '02'){
                            $('#cc').layout('show',"west");

                        }else{
                           $('#cc').layout('hidden',"west");
                        }
                        var dataList =[];
                        $("#ledger").combobox("clear");
                        var  ledgerList = analyMsg.ledgerList;
                        if(ledgerList.length>0){
                            for(var i=0;i<ledgerList.length;i++){
                                dataList.push({"value": ledgerList[i].dictCode,"text":ledgerList[i].dictName});
                            }
                            $("#ledger").combobox("loadData",dataList);

                            if(ledgerList.length==1){
                                $('#ledger').combobox('setValue', ledgerList[0].dictCode);
                            }else{
                                $('#ledger').combobox('setValue', analyMsg.ledger);
                            }
                            
                        }
                        //禁止修改
//                        $("#sel_sbzq").combobox("disable");
//                        $('#sel_sz').combobox('disable');
//                        $("#sel_ssq_nd").combobox("disable");
//                        $("#sel_ssq_xh").combobox("disable");
//                        $("#txt_ssq_q").attr("disabled", "disabled");
//                        $("#txt_ssq_z").attr("disabled", "disabled");
//                        
                        var rows = analyMsg.dictDtoList;
                        if(rows==null){
                            return
                        }
                        
                        var dataList = [];
                        for (var i = 0; i < rows.length; i++) {
                            dataList.push({"value": rows[i].dictCode, "text": rows[i].dictName});
                        }
                        $("#sel_sbzq").combobox("loadData", dataList);
                        $('#sel_sbzq').combobox('setValue', analyMsg.tdperdCode);
                        $("#sel_ssq_nd").val(analyMsg.year);
                        refresh_ssq_xh_update(analyMsg.tdperdCode);
                        

                        $("#sel_ssq_xh").combobox("setValue", analyMsg.date);
                        
                        $.fn.zTree.init($("#treeDemo"), setting, analyMsg.initData);
                        //默认第一个节点选中
                        var zTree = $.fn.zTree.getZTreeObj("treeDemo");
                        var node = zTree.getNodeByParam('pId', 0);
                        zTree.selectNode(node);
                        zTree.setting.callback.onClick(null, null, node);
                    }
                },
                error: function (data, textstatus) {
//                    $.messager.alert('错误', data.responseText, 'error', function () {
//                    });
                }
            });
        }
        Date.prototype.Format = function (fmt) {
            var o = {
                "M+": this.getMonth() + 1, //月份 
                "d+": this.getDate(), //日 
                "h+": this.getHours(), //小时 
                "m+": this.getMinutes(), //分 
                "s+": this.getSeconds(), //秒 
                "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
                "S": this.getMilliseconds() //毫秒 
            };
            if (/(y+)/.test(fmt))
                fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o) {
                if (new RegExp("(" + k + ")").test(fmt)) {
                    fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
                }
            }
            return fmt;
        }


        function getValues() {
            var param = new Object();
            var sz_dm = $("#sel_sz").combobox("getValue");
            var sbzq_dm = $("#sel_sbzq").combobox("getValue");

            var ssq_q = $("#txt_ssq_q").val();
            var ssq_z = $("#txt_ssq_z").val();

            var array =  ssq_q.split("-");
            var  taxperdFrom = new Date(array[0], array[1]-1, array[2]);
            var array2 =  ssq_z.split("-");
            var  taxperdTo = new Date(array2[0], array2[1]-1, array2[2]);

            var sbrq_q = $("#txt_sbrq_q").val();
            var sbrq_z = $("#txt_sbrq_z").val();

            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
            var node = treeObj.getSelectedNodes();
            
            if(node!=null){
                param.cbid = node[0].id;
            }else{
                param.cbid = "-1";
            }
            var node ="";
            var nodes ="";
            var orgCodes = "";//数据来源用于分支机构增加
            //纳税主体Id
            var taxPayerId="";
            //台账类别
            var ldgTypeCode ="";
            var flag="";
            if(treeObj!=null){

                flag="2";//汇总保存逻辑
                //获取所有节点信息
                node = treeObj.getNodes();
                nodes = treeObj.transformToArray(node);
                var length = nodes.length-1;
                for(var i=0; i<nodes.length; i++) {
                    if (i < length) {
                        taxPayerId += nodes[i].code + ',';
                    } else {
                        taxPayerId += nodes[i].code;
                    }
                }
            }else{
                flag="1";//分支保存逻辑
                taxPayerId =  $("#taxPayers").combobox("getValue");
                orgCodes = commonOrg();
                ldgTypeCode =  $("#ledger").combobox("getValue");;
                param.ldgTypeCode = ldgTypeCode
            }
            param.ldgTypeCode = $("#ledger").combobox("getValue")
                //税种编码
            param.taxCode = sz_dm;
            //属期
            param.taxperd = getTaxPerd();
            //申报周期
            param.tdperdCode = sbzq_dm;
            //税种类别taxTypeCode
            param.taxperdFrom = taxperdFrom;
            param.taxperdTo = taxperdTo;
            param.taxPayerId = taxPayerId;
            param.orgCode = orgCodes;
            param.startDate = taxperdFrom;
            param.endDate = taxperdTo;
            param.flag= flag;
            return param;
        }
        
        function checkInput() {
            var sz_dm = $("#sel_sz").combobox("getValue");
            if (sz_dm == null || sz_dm.length == 0 || sz_dm == "null" || sz_dm == "-1") {
                $.messager.alert('提示', '税（费）种不能为空，请选择税（费）种。', 'info',function(){});
                return false;
            }

            var sbzq_dm = $("#sel_sbzq").combobox("getValue");
            if (sbzq_dm == null || sbzq_dm.length == 0 || sbzq_dm == "null" || sbzq_dm == "-1") {
                $.messager.alert('提示', '申报周期不能为空，请选择申报周期。', 'info',function(){});
                return false;
            }

            var ssq_nd = $("#sel_ssq_nd").val();
            if (ssq_nd == null || ssq_nd.length == 0 || ssq_nd == "null" || ssq_nd == "-1") {
                $.messager.alert('提示', '所属期不能为空。', 'info',function(){});
                return false;
            }

            if (sbzq_dm != "12") {
                var ssq_xh = $("#sel_ssq_xh").combobox("getValue");
                if (ssq_xh == null || ssq_xh.length == 0 || ssq_xh == "null" || ssq_xh == "-1") {
                    $.messager.alert('提示', '所属期不能为空。', 'info',function(){});
                    return false;
                }
            }

            if (sbzq_dm == "03") {
                var ssq_q = $("#txt_ssq_q").val();
                if (ssq_q == null || ssq_q.length == 0) {
                    $.messager.alert('提示', '所属期起不能为空。', 'info',function(){});
                    return false;
                }

                var ssq_z = $("#txt_ssq_z").val();
                if (ssq_z == null || ssq_z.length == 0) {
                    $.messager.alert('提示', '所属期止不能为空。', 'info',function(){});
                    return false;
                }
            }

//            var ledger = $('#ledger').combobox("getValue");
//            if (ledger == null || ledger.length == 0) {
//                $.messager.alert('提示', '台账设置不能为空，请设置台账。', 'info',function(){});
//                return false;
//            }

//            //var arr = $("#tt").datagrid("getSelections");
//            var arr = $.fn.zTree.getZTreeObj("treeDemo");
//            if (arr == null || arr.length == 0) {
//                $.messager.alert('提示', '纳税主体不能为空，请选择纳税主体。', 'info',function(){});
//                return false;
//            }

            return true;
        }

        function DayNumOfMonth(Year, Month) {
            var d = new Date(Year, Month, 0);
            return d.getDate();
        }

        /**
         * @method      [addTaxpayer]
         * @description [增加纳税主体]
         * @author      [yangruidong]
         * @version     1.0
         * @param
         * @return
         * @exception
         * @date
         */
        function addTaxpayer() {

            var sz_dm = $("#sel_sz").combobox("getValue");
            if (sz_dm == null || sz_dm.length == 0 || sz_dm == "null" || sz_dm == "-1") {
                $.messager.alert('提示', '请先选择税（费）种。', 'info', function () {
                });
                return false;
            }

            var sbzq_dm = $("#sel_sbzq").combobox("getValue");
            if (sbzq_dm == null || sbzq_dm.length == 0 || sbzq_dm == "null" || sbzq_dm == "-1") {
                $.messager.alert('提示', '请先选择申报周期。', 'info', function () {
                });
                return false;
            }

            var cdmk = new refTree('taxpayer', '纳税主体树');
            var object = new Object();
            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
            var node = "";
            var nodes = "";
            //纳税主体Id
            var taxPayerId = "";
            if (treeObj != null) {
                //获取所有节点信息
                node = treeObj.getNodes();
                nodes = treeObj.transformToArray(node);
                var length = nodes.length - 1;
                for (var i = 0; i < nodes.length; i++) {
                    if (i < length) {
                        taxPayerId += nodes[i].code + ',';
                    } else {
                        taxPayerId += nodes[i].code;
                    }
                }
            }

            var taxCode =$("#sel_sz").combobox("getValue");
            var period =$("#sel_sbzq").combobox("getValue");

            cdmk.url = path+'/tdm/declareParameter/queryTaxpayerData?taxPayerId='+taxPayerId+"&taxCode="+taxCode+"&period="+period;
            cdmk.parameters = object;
            cdmk.callBack = batchAdd;
            cdmk.singleLoad = 0;
            cdmk.selectedMulti = 1;
            cdmk.init();
            cdmk.openRef();
        }

        function batchAdd() {
            var zTree = $.fn.zTree.getZTreeObj('taxpayer');

            var checkNodes = zTree.getCheckedNodes(true);

            if(checkNodes.length==0){
                $.messager.alert('操作提示','请选择至少一个主体','info',function(){});
                return;
            }

            //获取根节点
            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");

            if (treeObj != null) {
                var node = treeObj.getNodeByParam('pId', 0);
                var pTaxpayerCode = "";
                if (node != null) {
                    pTaxpayerCode = node.code;
                }
            }

            var length = checkNodes.length - 1;
            //选择数据得code 也就是纳税主体codes
            var codes = "";
            for (var i = 0; i < checkNodes.length; i++) {
                if (i < length) {
                    codes += checkNodes[i].code + ',';
                } else {
                    codes += checkNodes[i].code;
                }
            }
            //税种
            var taxCode = $("#sel_sz").combobox("getValue");
            //周期
            var tdPerdCode = $("#sel_sbzq").combobox("getValue");

            //属期
            var taxPerd = getTaxPerd();

            var ssq_q = $("#txt_ssq_q").val();
            var ssq_z = $("#txt_ssq_z").val();

            var array =  ssq_q.split("-");
            var  taxperdFrom = DateUtils.format(new Date(array[0], array[1]-1, array[2]), 'yyyy-MM-dd');
            var array2 =  ssq_z.split("-");
            var  taxperdTo =DateUtils.format( new Date(array2[0], array2[1]-1, array2[2]), 'yyyy-MM-dd');
            var ledger = $("#ledger").combobox("getValue");
            var url =path+"/tdm/declareParameter/saveTaxpayer?codes="+codes+"&pTaxpayerCode="+pTaxpayerCode+"&taxCode="+taxCode+"&tdPerdCode="+tdPerdCode+"&taxPerd="+taxPerd+"&ledger="+ledger;
           // var url =path+"/tdm/declareParameter/saveTaxpayer?codes="+codes+"&pTaxpayerCode="+pTaxpayerCode+"&taxCode="+taxCode+"&tdPerdCode="+tdPerdCode+"&taxPerd="+taxPerd+"&taxperdFrom="+taxperdFrom+"&taxperdTo="+taxperdTo;
//            var url =path+"/tdm/declareParameter/saveTaxpayer?codes="+codes+"&pTaxpayerCode="+pTaxpayerCode+"&taxCode="+taxCode+"&tdPerdCode="+tdPerdCode+"&taxPerd="+taxPerd;
            $.ajax({
                type: "POST",
                url: url,
                //data:params,
                dataType: "json",
                success: function callback(data) {
                    var analyMsg = data.returnObject;
                    if (data.code == "0000") {
                        $.fn.zTree.init($("#treeDemo"), setting, analyMsg.initData);
                        //默认第一个节点选中
                        var zTree = $.fn.zTree.getZTreeObj("treeDemo");
                        var node = zTree.getNodeByParam('pId', 0);
                        zTree.selectNode(node);
                        zTree.setting.callback.onClick(null, null, node);
                    } else {
                        $.messager.alert('信息', data.msg, 'info', function () {
                        });
                    }
                }
            });
        }


        /**
         * @method      [delOrg]
         * @description [删除纳税主体]
         * @author      [yangruidong]
         * @version     1.0
         * @param
         * @return
         * @exception
         * @date
         */
        function delTaxpayer() {
            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
            var node = treeObj.getSelectedNodes();
            var length = node.length - 1;

            if (node.length <= 0) {
                $.messager.alert("信息", "请选择一个纳税主体！", "info");
                return;
            }
            $.messager.alert("信息", "是否该纳税主体删除？","confirm", function () {

                    var taxPayerCode = "";
                    //先移除选择节点，数据在后台处理
                    for (var i = 0; i < node.length; i++) {
                        //移除
                        treeObj.removeNode(node[i]);
                        if (i < length) {
                            taxPayerCode += node[i].code + ',';
                        } else {
                            taxPayerCode += node[i].code;
                        }
                    }

                    params.taxCode = $("#sel_sz").combobox("getValue");
                    params.tdPerdCode = $("#sel_sbzq").combobox("getValue");
                    params.taxPayerCode = taxPayerCode;
                    params.cbid = node[0].id;
                    $.ajax({
                        type: "POST",
                        url: path + "/tdm/declareParameter/deleteTaxpayer",
                        data: params,
                        dataType: "json",
                        success: function callback(data) {
                            var analyMsg = data.returnObject;
                            if (data.code == "0000") {
                                //清空机构列表
                                $('#tt').treegrid('loadData', []);
                            } else {
                                $.messager.alert('信息', data.msg, 'info', function () {
                                });
                            }
                        }
                    });

            });
        }

        
        /**
         * @method      [delOrg]
         * @description [删除数据来源]
         * @author      [yangruidong]
         * @version     1.0
         * @param
         * @return
         * @exception
         * @date
         */
        function delOrg() {

            var deletNode = $('#tt').treegrid('getSelected');

            if (deletNode == null) {
                $.messager.alert("信息", "请选择数据来源机构", "info");
                return;
            }

            $.messager.alert('确认', '您确定要删除此选中行吗?', function () {

                    $('#tt').treegrid('remove', deletNode.orgCode);

                    var obj_node = $('#tt').treegrid('getRoots');

                    var length = obj_node.length - 1;
                    var orgCodes = "";
                    for (var i = 0; i < obj_node.length; i++) {
                        if (i < length) {
                            orgCodes += obj_node[i].orgCode + ',';
                        } else {
                            orgCodes += obj_node[i].orgCode;
                        }
                    }
                    var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
                    var nodes = treeObj.getSelectedNodes();
                    //新增数据来源，删除数据来源调用方法一样
                    params.taxpayerId = orgCodes;
                    params.cbid = nodes[0].id;

                    $.ajax({
                        type: "POST",
                        url: path + "/tdm/declareParameter/deleteOrAddOrgCodes",
                        data: params,
                        dataType: "json",
                        success: function callback(data) {
                            var analyMsg = data.returnObject;
                            if (data.code == "0000") {

                            } else {

                            }
                        }
                    });

            });

        }
       
     
        function callback_selectLedger(data) {
            params = data;
        }
        function closeBtn() {
            setTimeout("closeLayer()", 100);//设置延时，防止IE下出现异常
        }

        function checkTaxPayer() {
            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
            if (treeObj == null) {
                return false;
            } else {
                return true;
            }
        }

        //保存增加的数据
        function submit_Add() {
//            if (!checkInput()) {
//                return;
//            }
//            setTimeout("closeLayer()", 100);//设置延时，防止IE下出现异常
            if (!checkInput()) {
                return;
            }

            var url = '${path}/tdm/declareParameter/saveAllMessage';
            var param = getValues();

            $.ajax({
                type : "POST",
                url : url,
                dataType : "json",
                data: param,
                success : function callback(data) {
                    if (data.code != '0000') {
                        $.messager.alert('错误', data.msg, 'error',function() {});
                    } else {
                        $.messager.alert("提示", "修改成功。", "info",function(){
//                            parent.btnQuery();
                            closeLayer();
//                            setTimeout("closeLayer()", 100);//设置延时，防止IE下出现异常
                        });
                    }
                },
                error : function(data, textstatus) {
                    $.messager.alert('错误', data.responseText, 'error',function(){});
                }
            });
        }
    </script>
</head>
<body  style="margin:0px; padding:0px;" >

<div class="easyui-layout" fit="true" >

    <input type="hidden" value="${orgName}" id="orgName">
    <input type="hidden" id="cbid" name="cbid" value="${cbid}">
    <input type="hidden" id="cpid" name="cpid" value="${cpid}">
    <div data-options="region:'north',title:'申报参数',split:false,border: true" style="padding: 5px; height: 120px; background: none repeat scroll 0 0 #EFEFEF;">
        <form id="sbcsForm" method="post" >
            <table align="center" cellspacing="1">
                <colgroup>
                    <col style="width:150px;"></col>
                    <col style="width:250px;"></col>
                    <col style="width:150px;"></col>
                    <col style="width:250px;"></col>
                </colgroup>
                <tr>
                    <td align="right">
                        纳税主体：
                    </td>
                    <td align="left">

                        <select class="easyui-combobox" id="taxPayers" name="sel_sz" style="width:250px;" data-options="editable: false">
                            <%--<option value="">--请选择--</option>--%>
                            <c:forEach var="item"  items="${taxPayers}">
                                <option value="${item.id}">${item.name}</option>
                            </c:forEach>
                        </select>
                    </td>

                    <td align="right">
                        税（费）种：
                    </td>
                    <td align="left">

                        <select class="easyui-combobox" id="sel_sz" name="sel_sz" style="width:250px;" data-options="editable: false">
                            <%--<option value="">--请选择--</option>--%>
                            <c:forEach var="item"  items="${taxClassList}">
                                <option value="${item.dictCode}">${item.dictName}</option>
                            </c:forEach>
                        </select>
                    </td>

                </tr>
                <tr>
                    <td align="right">
                        申报周期：
                    </td>
                    <td align="left">

                        <select class="easyui-combobox" id="sel_sbzq" name="sel_sbzq" style="width:250px;"  onchange="initData(this.value)" data-options="editable: false">
                            <option value="">--请选择--</option>
                        </select>
                    </td>
                    <%--<td align="right">--%>
                        <%--所属期：--%>
                    <%--</td>--%>
                    <%--<td align="left">--%>
                        <%--<select id="sel_ssq_nd" name="sel_ssq_nd" class="easyui-combobox" style="width:104px;" data-options="editable: false, required: false">--%>
                            <%--<option value="">--请选择--</option>--%>
                            <%--&lt;%&ndash;<c:forEach var="item"  items="${yearList}">&ndash;%&gt;--%>
                            <%--&lt;%&ndash;<option value="${item.dictCode}">${item.dictName}</option>&ndash;%&gt;--%>
                            <%--&lt;%&ndash;</c:forEach>&ndash;%&gt;--%>
                        <%--</select>年--%>
                        <%--<select id="sel_ssq_xh" name="sel_ssq_xh" class="easyui-combobox" style="width:104px;" data-options="editable: false, required: false">--%>
                            <%--<option value="">--请选择--</option>--%>
                        <%--</select>--%>
                        <%--<span id="span_ssq_xh">期</span>--%>
                    <%--</td>--%>
                    <td align="right">申报属期：</td>
                    <td align="left">
                        <input id="sel_ssq_nd" name="sel_ssq_nd" class="Wdate"  style="width: 140px;" onChange="yearChange()" data-options="editable: false"> 
                        <select id="sel_ssq_xh" name="sel_ssq_xh" class="easyui-combobox" style="width:80px;" data-options="editable: false, required: false">
                            <option value="">--请选择--</option>
                        </select>
                        <span id="span_ssq_xh">期</span>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        所属期起止：
                    </td>
                    <td align="left">
                        <input type="text" id="txt_ssq_q" name="txt_ssq_q" class="Wdate" style="width: 100px;" onFocus="WdatePicker()" data-options="editable: false"> - <input type="text" id="txt_ssq_z" name="txt_ssq_z" class="Wdate" style="width: 100px;" onFocus="WdatePicker()" data-options="editable: false">
                    </td>

                    <td align="right">
                        台账设置：
                    </td>
                    <td align="left">

                        <select class="easyui-combobox" id="ledger" name="ledger" style="width:250px;"  onchange="initData(this.value)" data-options="editable: false">
                            <%--<option value="-1">--请选择--</option>--%>
                        </select>
                    </td>

                </tr>
            </table>
        </form>
    </div>





    <div region="center" style="padding: 5px;"  border="false">
        <div id="cc" class="easyui-layout"  fit="true"  border="false">
            <div data-options="region:'west',split:false"  border="true" noheader="true" split="false"  title="汇总分支机构" style="width:50%;">
                <div class="easyui-layout" fit="true"  border="false">
                    <div region="center" class ="panel-title" title="" border="false" >

                        <div class="panel-header">
                            <span>汇总分支机构</span>&nbsp;&nbsp;&nbsp;
                            <a id="btn_addNode_org" href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-add" plain="false" onclick="addTaxpayer()">新增</a>

                            <a id="btn_delNode_org2" href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-remove" plain="false" onclick="delTaxpayer()">删除</a>
                        </div>
                        <div region="center" title="" border="false" noheader="true"
                             style="padding: 5px 0 0 0;overflow-y:hidden;">
                            <div>
                                <ul id="treeDemo" class="ztree" style="width: 90%; height: 90%;">

                                </ul>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
            <div data-options="region:'center',title:'数据来源'" border="true" noheader="true" split="false"  style="width:50%;">
                <div class="easyui-layout" fit="true"  border="false">
                    <div region="center" class ="panel-title" title="数据来源" border="false" style="height:50%;">

                        <div class="panel-header">
                            <span>数据来源</span>&nbsp;&nbsp;&nbsp;
                            <a id="btn_addNode_org" href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-add" plain="false" onclick="addOrg()">新增</a>
                            <a id="btn_delNode_org2" href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-remove" plain="false" onclick="delOrg()">删除</a>
                        </div>
                        <div region="center" title="" border="false" noheader="true"
                             style="padding: 5px 0 0 0;overflow-y:hidden;">
                            <table id="tt" title="" border="false"></table>
                        </div>
                    </div>

                </div>

            </div>
        </div>
    </div>
    <div data-options="region:'south',title:'',split:false,border: false" style="height:55px;">
        <div align="center" style="margin-top: 15px;">
            <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="submit_Add()">确定</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="closeBtn();">取消</a>
        </div>
    </div>
</div>
</div>
</div>

</body>
</html>
